package com.bianxianmao.duobao.fragment;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.bianxianmao.R;
import com.bianxianmao.base.BaseFragment;

import static com.igexin.sdk.GTServiceManager.context;

/**
 * Created by Administrator on 2017/7/11.
 */
public class PopularityFragment extends BaseFragment {
    private Context mContext;

    private RecyclerView recyclerView;

    @Override
    public void initData() {

    }

    @Override
    public View initView() {
        View view = View.inflate(mContext, R.layout.fragment_poplarity, null);
        recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
        recyclerView.setLayoutManager(new GridLayoutManager(context, 2));
//        recyclerView.setAdapter(new PopularityAdapter(mContext,bean));

        return view;
    }

//    private PullToRefreshGridView pulltogridview;
//     private PopularityGridViewAdapter adapter;
//    private GridView gridView;
//    private String path;
//
//    public Handler mHandler = new Handler() {
//
//        @Override
//        public void handleMessage(Message msg) {
//            super.handleMessage(msg);
//            msg.what=2;
//            gridView.setNumColumns(2);
//            adapter = new PopularityGridViewAdapter(mContext);
//            adapter.setPopularityData((PopularityBean) msg.obj);
//
//            gridView.setAdapter(adapter);
//        }
//    };
//    private PullToRefreshGridView mPullToRefreshGridView;
//
//    @Override
//    public View initView() {
//
//        View view = View.inflate(mContext, R.layout.fragment_poplarity, null);
//        mPullToRefreshGridView = (PullToRefreshGridView) view.findViewById(R.id.pull_to_refresh);
//
//        GridView gridView = mPullToRefreshGridView.getRefreshableView();
//        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                PopularityBean.ReturnValueBean popularitybean = (PopularityBean.ReturnValueBean) parent.getItemAtPosition(position);
//                int productId = popularitybean.getProductId();
//                Intent intent = new Intent(getActivity(), DetailActivity.class);
//                intent.putExtra("productId",productId);
//                startActivity(intent);
//            }
//        });
//
//        initPopularity();
//        return view;
//    }
//    public PopularityFragment(){
//
//        }
//        private void initPopularity() {
//            Bundle bundle = getArguments();
//            path = bundle.getString("KEY");
//           final String url = Constants.POPULARITYUL;
//                new Thread(new Runnable() {
//                    @Override
//                    public void run() {
//                        OkHttpUtils.get().url(url).build().execute(new StringCallback() {
//                            @Override
//                            public void onError(Request request, Exception e) {
//
//                            }
//                            @Override
//                            public void onResponse(String response) {
//                                PopularityBean popularityBean = JSON.parseObject(response, PopularityBean.class);
//                                Message message = Message.obtain();
//                                message.what=2;
//                                message.obj= popularityBean;
//                                mHandler.sendMessage(message);
//                            }
//                        });
//                    }
//                });
////            OkHttpUtils.get().url(url).build().execute(new StringCallback() {
////                @Override
////                public void onError(Request request, Exception e) {
////                }
////                @Override
////                public void onResponse(String response) {
////                    Log.i("BBB", "onResponse: " + response);
////                    Gson gson = new Gson();
////                    PopularityBean popularityBean = gson.fromJson(response, PopularityBean.class);
////
////                    List<PopularityBean.ReturnValueBean> data = popularityBean.getReturnValue();
////
////                    for (int i = 0; i < data.size(); i++) {
////                        list.add(data.get(i));
////                    }
////                }
////            });
////            adapter.notifyDataSetChanged();
//        }
}

